package tools;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.image.BufferedImage;

import javax.swing.JComponent;

public class ShowImage extends JComponent {
	BufferedImage bi = null;
	AffineTransform at = new AffineTransform();
	
	public ShowImage(BufferedImage img) {
		this.bi = img;
		this.setPreferredSize(new Dimension(bi.getWidth(), bi.getHeight()));
	}
	
	public ShowImage(BufferedImage img, AffineTransform at) {
		this(img);
		this.at = at;
		Point2D dimension = new Point2D.Double(bi.getWidth(), bi.getHeight());
//		at.transform(dimension, dimension);
		this.setPreferredSize(new Dimension((int)dimension.getX(), (int)dimension.getY()));
	}
	@Override
	public void paint(Graphics g) {
		Graphics2D g2 = (Graphics2D)g;
		g2.drawImage(bi, at, this);
		super.paint(g);
	}

}
